﻿<Window x:Class="WpfApplicationTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplicationTest"
        xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
        Title="MainWindow" Height="650" Width="650"
        x:Name="_self"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance local:MainViewModel,IsDesignTimeCreatable=True}"
        >
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Slider x:Name="_slider" HorizontalAlignment="Left" Value="{Binding Path=Speed}" Margin="20" Orientation="Vertical" Maximum="{Binding Path=MaxValue}" Grid.Column="1" Grid.Row="0"></Slider>
        <Slider x:Name="_maximum" HorizontalAlignment="Center" Value="{Binding Path=MaxValue}" Margin="20" Orientation="Vertical" Maximum="200" Grid.Column="1" Grid.Row="0"></Slider>

        <Slider x:Name="_alarm" HorizontalAlignment="Right" Value="{Binding Path=Alarm,Mode=TwoWay}" Margin="20" Orientation="Vertical" Maximum="1" Grid.Column="1" Grid.Row="0"></Slider>
        
        <controls:AnalogGauge  
            x:Name="_gaugeSpeed"
            NeedleRadius="80" 
            Value="{Binding Path=Speed}" 
            MaxValue="{Binding Path=Maximum,ElementName=_slider}"
            NeedleBase="Gray" 
            NeedleBaseRadius="10" 
            BezelThickness="5" 
            Height="200" 
            Width="200" 
            Sweep="270" 
            StartAngle="225"
            BezelCornerRadius="150"
            Response="0"
            BaseBackground="{Binding Path=ScaleBackground,ElementName=_gaugeSpeed}" Margin="0,-7,14,12">
            <controls:AnalogGauge.BezelBackground>
                <RadialGradientBrush Center="0.5,0.5" RadiusX="1" RadiusY="1" GradientOrigin="0.5,0.5">
                    <GradientStop Color="LightGray" Offset="0.0"></GradientStop>
                    <GradientStop Color="DarkGray" Offset="0.25"></GradientStop>
                    <GradientStop Color="Gray" Offset="0.50"></GradientStop>
                    <GradientStop Color="Black" Offset="0.75"></GradientStop>
                    
                </RadialGradientBrush>
            </controls:AnalogGauge.BezelBackground>
            
            <controls:AnalogGauge.ScaleBackground>
                <RadialGradientBrush Center="0.5,0.5" RadiusX="1" RadiusY="1" GradientOrigin="0.5,0.5">
                    <GradientStop Color="LightGray" Offset="0.0"></GradientStop>
                    <GradientStop Color="DarkGray" Offset="0.25"></GradientStop>
                    <GradientStop Color="Black" Offset="0.50"></GradientStop>
                    <GradientStop Color="Black" Offset="0.75"></GradientStop>

                </RadialGradientBrush>
            </controls:AnalogGauge.ScaleBackground>
            <controls:AnalogGauge.RangeDefinitions>

                <controls:RangeDefinition Min="{Binding Path=Alarm}" Max="1.0" Stroke="Firebrick" Thickness="20"></controls:RangeDefinition>
            </controls:AnalogGauge.RangeDefinitions>
            <controls:AnalogGauge.Captions>
                <controls:GaugeCaption Size="20" X="75" Y="130"  Text="{Binding Path=Label}" Foreground="White"></controls:GaugeCaption>
                <controls:GaugeCaption Size="20" X="70" Y="55"  Text="{Binding Path=SpeedText}" Foreground="White"></controls:GaugeCaption>
            </controls:AnalogGauge.Captions>
            <controls:AnalogGauge.Scale>
                <controls:Scale MajorTickSize="6" TextRadius="75" Radius="90" Stroke="White" StrokeThickness="2" MajorTick="10" MinorTick="20"/>
            </controls:AnalogGauge.Scale>
        </controls:AnalogGauge>
        <Slider x:Name="_slider2" Margin="20" Orientation="Vertical" Maximum="{Binding Path=MaxAmps}" Grid.Column="1" Grid.Row="1"></Slider>
        <controls:AnalogGauge 
            x:Name="_gauge" 
            Grid.Row="1"
            NeedleRadius="95" 
            MaxValue="{Binding Path=Maximum,ElementName=_slider2}"
            Value="{Binding Path=Value,ElementName=_slider2}" 
            NeedleBase="Black" 
            NeedleBaseRadius="10" 
            BezelThickness="5" 
            Center="150,160"
            Height="200" 
            Width="300" 
            Sweep="120" 
            StartAngle="150"
            ScaleBackground="White"
            BezelCornerRadius="20" 
            BezelBackground="Black"
            BaseBackground="{Binding Path=ScaleBackground,ElementName=_gauge}">
            <controls:AnalogGauge.Scale>
                <controls:Scale MajorTickSize="9" TextRadius="120" Radius="141" Stroke="Black" StrokeThickness="2" MajorTick="12" MinorTick="24"/>
            </controls:AnalogGauge.Scale>
            <controls:AnalogGauge.RangeDefinitions>
                <controls:RangeDefinition Min="0" Max="0.5" Stroke="Green" Thickness="70"></controls:RangeDefinition>
                <controls:RangeDefinition Min="0.5" Max="0.75" Stroke="Orange" Thickness="70"></controls:RangeDefinition>
                <controls:RangeDefinition Min="0.75" Max="1.0" Stroke="Red" Thickness="70"></controls:RangeDefinition>
            </controls:AnalogGauge.RangeDefinitions>
            <controls:AnalogGauge.Captions>
                <controls:GaugeCaption Size="20" X="115" Y="170"  Text="Current" Foreground="Black"></controls:GaugeCaption>
                <controls:GaugeCaption Size="20" X="132" Y="80"  Text="mA" Foreground="White"></controls:GaugeCaption>
            </controls:AnalogGauge.Captions>
        </controls:AnalogGauge>
    </Grid>
</Window>
